/*
 * @Description:
 * @Author: wangqi
 * @Date: 2024-08-15 23:05:01
 * @LastEditTime: 2024-08-25 10:36:21
 * @LastEditAuthor: wangqi
 */
import { join, resolve } from 'path';
// import * as path from 'path';
import { readFileSync } from 'fs';
import * as yaml from 'js-yaml';
import * as _ from 'lodash';

console.log(__dirname, __filename, '__dirname');
/* 公共的config */
const configYmlPath = resolve(__dirname, '../config/config.yml');
console.log(configYmlPath, 'configYmlPath');
const configYmlContent = yaml.load(readFileSync(configYmlPath, 'utf8'));

/* dev | prod */
const dynamicsConfigYmlPath = resolve(
  __dirname,
  `../config/config.${process.env.NODE_ENV}.yml`,
);
const dynamicsConfigYmlContent = yaml.load(
  readFileSync(dynamicsConfigYmlPath, 'utf8'),
);

export default () => {
  return _.merge(configYmlContent, dynamicsConfigYmlContent);
};
